package com.ruoyi.web.studentmanagementsystem.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.web.studentmanagementsystem.dto.*;
import com.ruoyi.web.studentmanagementsystem.pojo.SysStudent;
import com.ruoyi.web.studentmanagementsystem.service.ISysStudentService;
import com.ruoyi.web.studentmanagementsystem.vo.SysStudentVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/ISysStudentService")
@Api(tags = "学生表接口相关")
public class StudentController {
    @Resource
    private ISysStudentService iSysStudentService;

    @PostMapping(  "/insertStudent")
    @ApiOperation("学生表——增")
    public R<String> insertStudent(@RequestBody ISysStudentDTO student) {
        iSysStudentService.insertStudent(student);
        return R.ok();
    }

    @PostMapping(  "/deleteStudentId/{studentId}")
    @ApiOperation("学生表——删")
    public R<String> deleteStudentId(@PathVariable String studentId) {
        iSysStudentService.deleteStudentId(studentId);
        return R.ok();
    }

    @PostMapping(  "/selectStudentName/{studentName}")
    @ApiOperation("学生表——查")
    public R<List<SysStudent>> selectStudentName(@PathVariable String studentName) {
        return R.ok(iSysStudentService.selectStudentName(studentName));
    }

    @PostMapping(  "/updateStudent")
    @ApiOperation("学生表——改")
    public R<String> updateStudent(@RequestBody IISysStudentDTO student) {
        iSysStudentService.updateStudent(student);
        return R.ok();
    }

    @PostMapping(  "/selectStudentAll")
    @ApiOperation("学生表——查（全体）")
    public R<List<SysStudentVO>> selectStudentAll() {
        return R.ok(iSysStudentService.selectStudentAll());
    }

    @PostMapping(  "/selectStudentAllId/{studentId}")
    @ApiOperation("学生表——查（全体-Id）")
    public R<List<SysStudentVO>> selectStudentAllId(@PathVariable String studentId) {
        return R.ok(iSysStudentService.selectStudentAllId(studentId));
    }
}
